// We can prove that if ALL of a noble's friends are weaker than it,
// that noble survives, otherwise it will die. 
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+7;
int weaker[maxn]; // Number of Weaker Friend
int n, m, q;
int nkill;
void addfri(int l, int r) {
  if(l>r) swap(l, r);
  weaker[l]++;
  if(weaker[l]==1) nkill++;
}
void delfri(int l, int r) {
  if(l>r) swap(l, r);
  weaker[l]--;
  if(weaker[l]==0) nkill--;
}
int slat() {
  return n - nkill; // Survivors
}
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin>>n>>m;
  for(int i=0; i<m; ++i) {
    int l, r; cin>>l>>r;
    addfri(l, r);
  }
  cin>>q;
  for(int i=0; i<q; ++i) {
    int t, u, v; cin>>t;
    switch(t) {
      case 1:
        cin>>u>>v; addfri(u, v); break;
      case 2:
        cin>>u>>v; delfri(u, v); break;
      case 3:
        cout<< slat() << '\n'; break;
    }
  }
}

